﻿using DynORM.Interfaces.BLLMapper.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynORM.BLLMapper
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class ForeignKeyDeclarationAttribute : Attribute
    {
        //this attribute applied:
        //in case of ManyToMany relationship to parent class (the class that has a member (which is collection) where the childs stored)
        //in other cases (ZeroToOne, ZeroToMany) this attribute applied to child class (the class which objects are stored in parent's class collection; there is no need to apply any attributes to the parent member in this case)

        public ForeignKeyDeclarationAttribute(Type foreignType, RelationQuantity relationQuantity, string memberName, int ord)
        {
            this.ForeignType = foreignType;
            this.RelationQuantity = relationQuantity;
            this.MemberName = memberName;
            this.Ord = ord;
        }

        
        public Type ForeignType { get; set; }
        public RelationQuantity RelationQuantity { get; set; }

        // in case of ManyToMany relation this is the name of class' member to which the attribute was applied
        // in other cases (ZeroToOne, ZeroToMany) this is the name of the parent class' member 
        public string MemberName { get; set; } 
        public int Ord { get; set; }
    }
}
